################################################################################
# Board: MKS Robin Nano v1.1 (Flying Bear Reborn 2.0) / MKS Robin Nano v1.3 / MKS Robin Nano-S v1.3
# Printer: Flying Bear Ghost 5 
# G-code Macros by MATVEI_IVANOV
################################################################################


# Marlin Compatibility #########################################################
[gcode_macro THROW_OFF_MODEL]
gcode: 
  M106 S0; fan 0ff
  M104 S0; turn off extruder 
  echo "Температура стола опустится до 45 градусов";
  M190 S35 ; Set bed temperature to 45 degrees Celsius and wait for it to reach the target
  echo "Температура стола 45 градусов";
  ;G91 ; Relative positioning
  ;G1 Z5 ; Raise the nozzle slightly to clear the printed model
  ;G90 ; Absolute positioning
  ;G28 ; Home all axes
  
  ;G1 Z10 ; Move Z-axis up slightly to clear the printed model
  ;G1 X0 Y0 ; Move to home position or another safe position

  G90 ; Absolute positioning
  ; Define parameters for the cleaning pattern
  $row_distance=20 ; Distance between rows (adjust as needed)
  $move_distance=100 ; Distance to move between cleaning passes (adjust as needed)
  $num_rows=5 ; Number of rows to clean

  ; Start cleaning pattern
  G1 X0 Y0 ; Move to the starting position
  G1 Z5 ; Lower the nozzle slightly for cleaning

  echo "Собираю урожай";
  ; Loop through rows
  FOR {row_num=1} {row_num<=$num_rows} {row_num+=1} DO
      ; Move in one direction across the bed
      G1 Y[$row_distance*$row_num]
      G1 X[$move_distance] F3000 ; Adjust feed rate as needed

      ; Move back in the opposite direction to cover the whole bed
      G1 Y0 F3000 ; Move back to the starting position
      G1 X[-$move_distance] F3000 ; Adjust feed rate as needed
  ENDFOR

  echo "Урожай собран. Наслаждайтесь жизнью";
  G1 Z10 ; Raise the nozzle after cleaning

  


